﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BrnMall.Manager.Manager.Store
{
    public static class StoreInfoManager
    {
        /// <summary>
        /// 是否开通分消息信息
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="hasdistributor">是否开通</param>
        public static void UpdateDistributor(int storeId, bool hasdistributor)
        {
            using (var db = new QDMallDatabase())
            {
                db.Execute("update bma_stores set hasdistributor=@0 where storeid=@1", hasdistributor, storeId);
            }
        }
        /// <summary>
        /// 是否开通分消息信息
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static bool CheckDistributor(int storeId)
        {
            using (var db = new QDMallDatabase())
            {
                return db.ExecuteScalar<bool>("select hasdistributor from bma_stores where storeid=@0", storeId);
            }
        }
        /// <summary>
        /// 获取店铺ID
        /// </summary>
        /// <param name="website">小程序网站域名</param>
        /// <returns></returns>
        public static int GetStoreIdByWebSite(string website)
        {
            object obj = null;
            using (var db = new QDMallDatabase())
            {
                obj = db.ExecuteScalar<object>("select top 1 storeid from bma_stores where website=@0", website);
            }
            if (obj == null || obj == DBNull.Value)
                return 0;
            return Convert.ToInt32(obj);
        }
    }
}
